﻿@model PagedList.PagedList<QuaLuuNiem.Models.SANPHAM>

@{
    ViewBag.Title = "danh_sach_san_pham";
    Layout = "~/Views/Shared/_layoutDangnhap.cshtml";
}
<div class="center_center">
<div class="center_danhsach">
<h2>danh sách các sản phẩm </h2>

<p>
    @Html.ActionLink("Thêm sản phẩm mới", "ThemSanPham")
</p>
@using (Html.BeginForm("danh_sach_san_pham","Admin"))
{
    <span>Nhập tên sản phẩm :</span> @Html.TextBox("key", ViewBag.CurrentFilter as string)
    <input type="submit" value="Tìm kiếm" />                 
}
<table width="950px" border="1" cellpadding="0" cellspacing="0">
    <tr>
        <th>
            Mã SP
        </th>
        <th>
            Loại SP
        </th>
        <th>
            Tên
        </th>
        <th>
            Đơn Giá
        </th>
        <th>
            Tóm tắt
        </th>
        <th width= "150px">
            Chi Tiết
        </th>
        <th>
            Hình
        </th>
        <th>
            Trạng Thái
        </th>
        <th>
            Menu
        </th>
        <th>Thao Tác</th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.MaSP)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LOAISANPHAM.TenLoai)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.TenSP)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DonGia) VNĐ
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.MoTaTomTat)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.MoTaChiTiet)
        </td>
        <td>
           
            <img src="../../Content/images/san_pham/@item.Hinh" />
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.TRANGTHAISP.TenTrangThai)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.MENURIGHT.TenMenu)
        </td>
        <td>
            @Html.ActionLink("Edit ", "CapNhatSanPham", new { id = item.MaSP }) |
            @Html.ActionLink(" Delete", "XoaSanPham", new { id = item.MaSP })
        </td>
    </tr>
}

</table>

    <div class="phan_trang">
         Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount
     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink(" << ", "danh_sach_san_pham", new { page = 1, currentFilter = ViewBag.CurrentFilter })
        @Html.Raw(" ");
        @Html.ActionLink(" Prev ", "danh_sach_san_pham", new { page = Model.PageNumber - 1, currentFilter = ViewBag.CurrentFilter })
    }
    else
    {
        @:Prev 
        @Html.Raw(" ");
        @:<<
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink(" Next ", "danh_sach_san_pham", new { page = Model.PageNumber + 1, currentFilter = ViewBag.CurrentFilter })
        @Html.Raw(" ");
        @Html.ActionLink(" >> ", "danh_sach_san_pham", new { page = Model.PageCount, currentFilter = ViewBag.CurrentFilter })
    }
    else
    {
        @:Next >>
        @Html.Raw(" ")
        @:>>
    }
</div>
</div>
</div>